package se19team1e.dao.abstrakt.generics;

import java.util.List;

import se19team1e.exception.DataAccessException;

/**
 * 
 * <p>
 * Interface for all DAO to use. It allows extensibility of more entities in
 * future. It takes the naming form from its properties file defined in the
 * transition strategy, so a concrete implementation of an account DAO would be
 * AccountDAO. For example, Account DTO would also extend from
 * DataTransferObject to make use of generic.
 * </p>
 * 
 * @author Arun Manivannan
 * 
 */
public interface DataAccessObject<T extends DataTransferObject> {

	/**
	 * Adds a new object to the persistence storage.
	 * 
	 * @param dtoType
	 * @return success state
	 * @throws DataAccessException
	 */
	public boolean create(T dtoType) throws DataAccessException;

	/**
	 * Deletes an existing object from the persistence storage by the given id.
	 * 
	 * @param idType
	 * @return success state
	 * @throws DataAccessException
	 */
	public boolean delete(Object idType) throws DataAccessException;

	/**
	 * Gets an existing object from the persistence storage by the given id.
	 * 
	 * @param idType
	 *            ID of the object of whichever type
	 * @return Object Depends on the type
	 * @throws DataAccessException
	 */
	public T retrieveById(Object idType) throws DataAccessException;

	/**
	 * Retrieve all objects of a corresponding type in the persistence storage.
	 * 
	 * @return collection of DataTransfer objects
	 * @throws DataAccessException
	 */
	public List<T> retrieveAll() throws DataAccessException;

	/**
	 * Updates the delta of an existing object to the persistence storage.
	 * 
	 * @param dtoType
	 * @return Object
	 * @throws DataAccessException
	 */
	public T update(T dtoType) throws DataAccessException;

}